import cv2 as cv
import sys
import os

path = '../../../large_data/pic/DSC05024_1.JPG'

img = cv.imread(cv.samples.findFile(path))

if img is None:
    sys.exit('Could not read the image.')

cv.imshow("Display window", img)
k = cv.waitKey(0)

if k == ord('s'):
    dir, fname = os.path.split(path)
    basename, ext = os.path.splitext(fname)
    path_png = os.path.join(dir, basename + '.png')
    r = cv.imwrite(path_png, img)
    print(r)
